include ("shared.lua")

ENT.LastSmoke = -1

function ENT:Think ()
	if not self.Entity:GetNWBool ("l") then return end
	self.SmokeTimer =self.SmokeTimer or 0
	if (self.SmokeTimer > CurTime()) then return end
	
	self.SmokeTimer = CurTime()+0.005

	local vOffset = self.Entity:LocalToWorld(Vector(0,0,self.Entity:OBBMins().z))

	local vNormal = (vOffset-self.Entity:GetPos()):GetNormal()

	local emitter = ParticleEmitter (vOffset)
	
		local particle = emitter:Add ("particles/smokey",vOffset)
			particle:SetVelocity (vNormal*math.Rand(10,20))
			particle:SetDieTime (1.0)
			particle:SetStartAlpha (math.Rand(100,150))
			particle:SetStartSize (math.Rand(5,10))
			particle:SetEndSize (math.Rand(20,50))
			particle:SetRoll (math.Rand(-0.2,0.2))
			particle:SetColor (160,160,160)
				
	emitter:Finish()
end

local Laser = Material( "cable/redlaser" ) 

function ENT:Draw()
	self:DrawModel()
	--[[for k,v in pairs (ents.FindByClass ("npc_helicopter")) do
		render.SetMaterial( Laser )
		render.DrawBeam (v:GetPos(), v:GetPos() + v:GetAngles():Forward() * 300, 5, 0, 0, Color (255,255,255,255))
		render.DrawBeam (v:GetPos(), v:GetPos() + v:GetAngles():Up() * 300, 5, 0, 0, Color (255,255,255,255))
		render.DrawBeam (v:GetPos(), v:GetPos() + v:GetAngles():Right() * 300, 5, 0, 0, Color (255,255,255,255))
	end]]
end
